import { create } from 'zustand';

const useFormStore = create((set) => ({
  name: '',
  isPending: false,
  error: null,
  updateName: async (newName) => {
    set({ isPending: true });
    try {
      await new Promise((resolve) => setTimeout(resolve, 1000));
      set({ name: newName, isPending: false, error: null });
    } catch (error) {
      set({ isPending: false, error: error.message });
    }
  },
}));

export default useFormStore;